#include <stdio.h>
#include <stdlib.h>
#include <csp_spu.h>
#include <csp_debug.h>

#include "../alting_test.h"


#define CHANNEL_NAME 42


int global_pid; 


int Run(){

	int pid = csp_pid();

	global_pid = csp_pid();

	int n __attribute ((aligned(16)));
	n = O2O_1_VALUE;

	int ret;

	csp_channel o2o_1;

	o2o_1 = csp_create_channel(ONE2ONE_CHANNEL, O2O_1_CHANNEL, sizeof(int));

	ret = csp_channel_write(o2o_1, &n);

	ASSERT( CHANNEL_SUCCESS == ret || CHANNEL_POISON == ret );
		

	ASSERT( pid == csp_pid() );
	ASSERT( global_pid == csp_pid() );

	PRINTF_FOR_TESTING("%s terminating on spe #%i with pid %i\n",__FILE__ , 
		csp_spe_id(), pid);

	PRINTF_FOR_TESTING("Nested task with pid=%i terminated with res=%i.\n", 
		pid, res);

	printf("der!\n");

	return 0;
}
